<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>新增基础数据</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="新增,基础,数据">
	<meta http-equiv="description" content="This is my page">

  </head>
  
  <body>
    <center>
    	<s:form name="frm" id="frm" method="post" action="" namespace="">
    		<s:hidden name="bd.parentId"></s:hidden>
    	
    		<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
    			<jsp:param name="menuLink" value="[{'name':'系统管理'},{'name':'数据管理'},{'name':'基础数据管理'},{'name':'新增基础数据'}]"/>
    			<jsp:param name="width" value="80%"/>
    		</jsp:include>
    		
    		<table width="100%" cellspacing="1" cellpadding="3" bgcolor="#CCCCCC">
    			<tr bgcolor="#FFFFFF">
    				<td width="20%" align="right" class="label">
    					键：
    					<br>
    					<font color="red">(50字以内)</font>
    				</td>
    				<td width="80%" align="left">
    					<s:textfield name="bd.id" id="bdId" cssStyle="width:100%" maxlength="50"></s:textfield>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td align="right" class="label">
    					值：
    				</td>
    				<td align="left">
    					<s:textfield name="bd.dataValue" id="dataValue" cssStyle="width:100%"></s:textfield>
    				</td>
    			</tr>
    			<tr bgcolor="#FFFFFF">
    				<td align="right" class="label">
    					排序：
    				</td>
    				<td align="left">
    					<s:textfield name="bd.sort" id="sort" cssStyle="width:100%"></s:textfield>
    				</td>
    			</tr>
    		</table>
    		
    		<table width="100%" cellspacing="0">
    			<tr>
    				<td align="center" valign="bottom" height="30">
    					<input type="button" value="新增" class="btn" onclick="addBaseData()" />
    				</td>
    			</tr>
    		</table>
    		
    		
    	</s:form>
    </center>
    
    <script type="text/javascript">
    function addBaseData()
    {
    	var bdId = $('#bdId');
    	var dataValue = $('#dataValue');
    	var sort = $('#sort');
    	var keyP = /^[a-zA-Z0-9\_]*$/;
    	if('' == bdId.val().Trim())
    	{
    		showMsg('键不能为空。', function(){bdId.focus();});
    		return;
    	}
    	if(!keyP.exec(bdId.val()))
    	{
    		showMsg('键只能为英文和数字', function(){bdId.focus();});
    		return;
    	}
    	if('' == dataValue.val().Trim())
    	{
    		showMsg('值不能为空。', function(){dataValue.focus();});
    		return;
    	}
    	if('' == sort.val().Trim() || ('' != sort.val().Trim() && checkInteger(sort) == false))
    	{
    		showMsg('排序只能为数字。', function(){sort.focus();});
    		return;
    	}
    	$.ajax({
    		url:'${CONTEXT_PATH}/inner/data/addBaseData.action',
    		type:'post',
    		data:$("#frm").serialize(),
    		dataType:'json',
    		success:
    			function(result){
    				if(result == true)
    				{
	    				showMsg('新增成功。', function(){
				    		window.close();
				    		window.opener.searchThis();
				    	});
			    	}
			    	else
			    	{
			    		showMsg('已存在该键，请重新输入。');
			    	}
    			}
    	});
    }
    </script>
  </body>
</html>
